<%--
  Created by IntelliJ IDEA.
  User: zuxia
  Date: 2018/7/19
  Time: 14:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="css/amazeui.min.css" />
    <link rel="stylesheet" href="css/admin.css" />
</head>

<body>
<div class="admin-content-body">
    <div class="am-cf am-padding am-padding-bottom-0">
        <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">菜品管理</strong><small></small></div>
    </div>

    <hr>

    <div class="am-g">
        <div class="am-u-sm-12 am-u-md-6">
            <div class="am-btn-toolbar">
                <div class="am-btn-group am-btn-group-xs">
                    <button type="button" class="am-btn am-btn-default btnAdd"><span class="am-icon-plus"></span> 新增</button>
                </div>
            </div>
        </div>
        <div class="am-u-sm-12 am-u-md-3">

        </div>

    </div>
    <div class="am-g">
        <div class="am-u-sm-12">
            <form class="am-form">
                <table class="am-table am-table-striped am-table-hover table-main" >
                    <thead>
                    <tr>
                        <th class="table-check"><input type="checkbox" id="chkAll"></th>
                        <th class="table-id">ID</th>
                        <th class="table-title">菜品名称</th>
                        <th class="table-type">菜品类型</th>
                        <th class="table-title">菜品图片</th>
                        <th class="table-title">菜品价格</th>
                        <th class="table-author am-hide-sm-only">菜品详情</th>
                        <th class="table-set">操作</th>
                    </tr>
                    </thead>
                    <tbody id="listMenu">

                    </tbody>
                </table>
                <div class="am-cf">
                    共  条记录
                    <div class="am-fr">
                        <ul class="am-pagination">
                            <li class="am-disabled">
                                <a href="#">«</a>
                            </li>
                            <li class="am-active">
                                <a href="#">1</a>
                            </li>
                            <li>
                                <a href="#">2</a>
                            </li>
                            <li>
                                <a href="#">3</a>
                            </li>
                            <li>
                                <a href="#">4</a>
                            </li>
                            <li>
                                <a href="#">5</a>
                            </li>
                            <li>
                                <a href="#">»</a>
                            </li>
                        </ul>
                    </div>
                </div>
                <hr>
            </form>
        </div>
    </div>
</div>

<script src="js/jquery-1.11.3.min.js"></script>
<!--<![endif]-->
<script type="text/javascript" src="myplugs/js/plugs.js"></script>
<script>
    $(function() {
        $("#chkAll").chkAll({
        });

        $(".btnAdd").click(function() {

            $.jq_Panel({
                title: "添加菜品信息",
                iframeWidth: 500,
                iframeHeight: 300,
                url: "addMenu.jsp"
            });

        });

        $.ajax({
            type:"get",
            datetype:"json",
            url:"/isFull-admin/listMenu.action",
            data:{},
            success:function (result) {
                var listMenu=result.data;
                for(var i=0;i<listMenu.length;i++){
                    $("#listMenu").append(
                   " <tr><td><input type='checkbox' name='chks' value='"+listMenu[i].meid+"'></td><td>"+listMenu[i].meid+"</td>"+
                        "<td> <a href='#'>"+listMenu[i].mname+"</a></td><td>"+listMenu[i].tid+"</td><td><img src='' alt='图片显示失败'/></td><td>"+listMenu[i].mprice+"</td><td>"+listMenu[i].mdetails+"</td>"+
                        "<td> <div class='am-btn-toolbar'> <div class='am-btn-group am-btn-group-xs'>"+
                        "<button class='am-btn am-btn-default btnedit'><span class='am-icon-pencil-square-o'></span> 修改</button>"+
                        "<button type='button' class='am-btn am-btn-default am-btn-xs am-text-danger amt-hide-sm-only  btndel' onclick='deleteDepart(14,1)'>" +
                        "<span class='am-icon-trash-o'></span> 删除</button></div> </div> </td> </tr>"
                    );
                }
            }
        });
        $("body").on("click",'.btndel',function() {
            var meid = $(this).parents("tr").children(":first").children("input").val();
           if (confirm("你确定提交吗？")) {
                $.ajax({
                    type:"get",
                    url:'/isFull-admin/deleteMenu.action',
                    dataType:"json",
                    data:{ meid },
                    success:function () {
                        $(location).prop('href', '/isFull-admin/menu.jsp');
                    }
                })
            }
        });
    });

    $("body").on("click",'.btnedit',function() {
        var meid = $(this).parents("tr").children(":first").children("input").val();
        $.ajax({
            type:"get",
            dataType:"json",
            data:{ meid },
            async: false,
            url:'/isFull-admin/queryMMname.action',
            success:function () {
            }
        })

        $.jq_Panel({
            title: "修改菜品信息",
            iframeWidth: 500,
            iframeHeight: 300,
            url: "btndel.jsp"
        });
    })
    $("#chkAll").click(function () {
        if($(this).prop("checked")){
            $("input[name=chks]").prop("checked",true);
        }else{
            $("input[name=chks]").prop("checked",false);
        }
    })
</script>
</body>

</html>